#!/bin/bash

build_folder="$(git rev-parse --show-toplevel)/CutBox/build"
archive_at="${build_folder}/archive/CutBox.xcarchive"

rm -rvf "${build_folder}/CutBox.app"
rm -rvf "${build_folder}/archive"

xcodebuild archive \
    -workspace CutBox/CutBox.xcworkspace \
    -scheme CutBox \
    -configuration Release \
    -archivePath "${archive_at}"

mv "${archive_at}/Products/Applications/CutBox.app" "${build_folder}"
codesign --deep --force -s - "${build_folder}/CutBox.app"
